package com.hongdee.market.costtag.mapper;

import com.hongdee.market.costtag.pojo.CostTagPoJo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author zhangkai
 * @desc 一句话描述
 **/
@Mapper
public interface ICostTagMapper {
    /***
     * 保存记录
     * @param costTagPojo
     */
    @Insert("insert into t_market_cost_tag(id,tag_code,tag_name,ref_type,ref_val,val_type,status,company_id)values(#{id}," +
            "#{tagCode},#{tagName},#{refType},#{refVal},#{valType},#{status},#{companyId})")
    @SelectKey(statement = "select  replace(uuid(),'-','')   from dual", keyProperty = "id", before = true, resultType = String.class)
    void Insert(CostTagPoJo costTagPojo);

    /***
     * 更新状态
     * @param id
     * @param status
     */
    @Update("update t_market_cost_tag set status= #{status} where id = #{id}")
    void UpdateStatus(@Param("id") String id, @Param("status") String status);

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @Select("select * from t_market_cost_tag where id = #{id}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "tag_code", property = "tagCode"),
            @Result(column = "tag_name", property = "tagName"),
            @Result(column = "ref_type", property = "refType"),
            @Result(column = "ref_val", property = "refVal"),
            @Result(column = "val_type", property = "valType"),
            @Result(column = "status", property = "status"),
            @Result(column = "company_id", property = "companyId")
    })
    CostTagPoJo Info(@Param("id") String id);

    /**
     * 分页查询
     */


    /**
     * 更新实体
     */
    @Update("update t_market_cost_tag set status= #{status},tag_code = #{tagCode} ,tag_name = #{tagName}," +
            "ref_type=#{refType},ref_val = #{refVal},val_type=#{valType} where id = #{id}")
    void UpdatePoJo(CostTagPoJo costTagPoJo);

    /**
     * 分页查询
     *
     * @param companyId
     * @return
     */
    @SelectProvider(type = CostTagQueryProvider.class, method = "list")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "tag_code", property = "tagCode"),
            @Result(column = "tag_name", property = "tagName"),
            @Result(column = "ref_type", property = "refType"),
            @Result(column = "ref_val", property = "refVal"),
            @Result(column = "val_type", property = "valType"),
            @Result(column = "status", property = "status"),
            @Result(column = "company_id", property = "companyId")
    })
    List<CostTagPoJo> list(@Param("companyId") String companyId);
}
